package com.delaphone.flocash.web.action;

import com.delaphone.flocash.model.FOrders;
import com.delaphone.flocash.service.AccountService;
import com.delaphone.flocash.service.PaymentService;

/**
 *
 * @author dongtv
 */
public class PayBillAction extends BaseAction {

    private PaymentService payment;
    private AccountService accountService;
    private int orderId;
    private FOrders order;
    private String message;

    public String pay_bill() {
        order = payment.getOrderById(user.getId(), orderId);
        return INPUT;
    }

    public String do_pay_bill() {
        order = payment.getOrderById(user.getId(), orderId);        
        boolean check = accountService.payBill(user.getAccount(), orderId, order.getAccountId());
        if (check) {
            message = getText("user.pay_bill.success");
        } else {
            message = getText("user.pay_bill.failed");
        }
        return SUCCESS;
    }

    public FOrders getOrder() {
        return order;
    }

    public PaymentService getPayment() {
        return payment;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public void setPayment(PaymentService payment) {
        this.payment = payment;
    }

    public AccountService getAccountService() {
        return accountService;
    }

    public void setAccountService(AccountService accountService) {
        this.accountService = accountService;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
